<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Device\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 广播服务器验证数据类
 */
class RdDeviceBroadcastServerRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'id',
            'name',
            'link',
            'username',
            'password',
            'auth',
            'remarks',
            'created_at',
            'updated_at',
        ],
        'create' => [
            'name',
            'link',
            'username',
            'password',
            'auth',
            'remarks',
        ],
        'update' => [
            'name',
            'link',
            'username',
            'password',
            'auth',
            'remarks',
        ]
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'id' => 'integer',
            //名称 验证
            'name' => 'max:255',
            //链接地址 验证
            'link' => 'max:255',
            //用户名 验证
            'username' => 'max:255',
            //密码 验证
            'password' => 'max:255',
            //认证 验证
            'auth' => 'max:255',
            //备注 验证
            'remarks' => 'max:255',

        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => 'ID',
            'name' => '名称',
            'link' => '链接地址',
            'username' => '用户名',
            'password' => '密码',
            'auth' => '认证',
            'remarks' => '备注',
            'created_by' => '创建者',
            'updated_by' => '更新者',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',

        ];
    }

    public function messages(): array
    {
        return [
            'id.integer' => 'ID必须是整数',
            'name.max' => '名称长度不能超过255个字符',
            'link.max' => '链接地址长度不能超过255个字符',
            'username.required' => '必填用户名',
            'username.max' => '用户名长度不能超过255个字符',
            'password.required' => '必填密码',
            'password.max' => '密码长度不能超过255个字符',
            'auth.required' => '必填认证',
            'auth.max' => '认证长度不能超过255个字符',
            'remarks.max' => '备注长度不能超过255个字符',
            'created_by.required' => '必填创建者',
            'updated_by.required' => '必填更新者',

        ];
    }
}